import cn.wolfcode.crm.util.JsonResult;
import freemarker.template.Configuration;
import freemarker.template.Template;
import freemarker.template.TemplateException;
import freemarker.template.Version;
import org.junit.Test;
import org.springframework.test.context.ContextConfiguration;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;

public class HelleFreemarker {

    @Test
    public void test() throws IOException, TemplateException {
        //要显示的数据
        System.out.println(1);
        JsonResult jsonResult = new JsonResult(true,"登陆成功");

        //创建一个freemarker对象
        Configuration configuration = new Configuration(Configuration.VERSION_2_3_23);
        //
        configuration.setDirectoryForTemplateLoading(new File("E:\\IdeaProjects\\crm\\src\\test"));

        Template template = configuration.getTemplate("hello.ftl", "utf-8");

        OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream("hello.html"));

        template.process(jsonResult,writer);

        writer.close();
    }
}
